/**
 * MyExpList.java
 * @author Marco Secchiero
 * 
 * This class represents the Expandable List Menu contained into the Menu View Activity.
 * It contains the main access methods to the effective definition of the ExpandableListView
 * referred by an adapter.
 */

package wfta.client.gui;

import wfta.client.ManagerStaticBuilder;
import android.content.Context;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;

public class MyExpList extends ExpandableListView {
	
	private MyExpListAdapter _expListAdp;
	
	private int _qtyOrdered = 0;

	public MyExpList(Context context) throws Exception {
		super(context);
		// TODO Auto-generated constructor stub
		_expListAdp = new MyExpListAdapter((MenuViewActivity) context,
				ManagerStaticBuilder.GetLastConnection().GetMenu());
	}
	
	@Override
	public ExpandableListAdapter getExpandableListAdapter() {
		return _expListAdp;
	}
	
	public void incrementQuantity(int groupPosition, int childPosition){
		_expListAdp.incrementCounter(groupPosition,childPosition);
		_qtyOrdered++;
	}

	public void decrementQuantity(int groupPosition, int childPosition){
		_expListAdp.decrementCounter(groupPosition,childPosition);
		if (_qtyOrdered>0) _qtyOrdered--;
	}
	
	public int getQtyOrdered() {
		return _qtyOrdered;
	};

}
